﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http.Headers;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;

namespace LogForParameter.Api
{
    public class GetHeader
    {
        public static string GetWPToken(IHeaderDictionary requestHeaders)
        {
            StringValues result;
            string WPtoken = "";
            if (requestHeaders.TryGetValue("WPtoken", out result))
            {
                WPtoken = result[0];
            }
            return WPtoken;
        }
        public static string GetUserid(IHeaderDictionary requestHeaders)
        {
            StringValues result;
            string userid = "";
            if (requestHeaders.TryGetValue("userId", out result))
            {
                userid = result[0];
            }
            return userid;
        }
        public static string GetPassword(IHeaderDictionary requestHeaders)
        {
            StringValues result;
            string password = "";
            if (requestHeaders.TryGetValue("password", out result))
            {
                password = result[0];
            }
            return password;
        }
        public static string GetToken(IHeaderDictionary requestHeaders)
        {
            StringValues result;
            string token = "";
            if (requestHeaders.TryGetValue("token", out result))
            {
                token = result[0];
            }
            return token;
        }
        public static string GetCookieStr(IHeaderDictionary requestHeaders)
        {
            StringValues result;
            string cookieStr = "";
            if(requestHeaders.TryGetValue("cookieStr", out result))
            {
                cookieStr = result[0];
            }
            return cookieStr;
        }
        public static string GetJobNumber(IHeaderDictionary requestHeaders)
        {
            StringValues result;
            string jobNumber = "";
            if (requestHeaders.TryGetValue("jobNumber", out result))
            {
                jobNumber = result[0];
            }
            return jobNumber;
        }
        public static string GetHosId(IHeaderDictionary requestHeaders)
        {
            StringValues result;
            string HosId = "";
            if (requestHeaders.TryGetValue("HospitalId", out result))
            {
                HosId = result[0];
            }
            return HosId;
        }

        /// <summary>
        /// 获取当前科室代码
        /// </summary>
        /// <param name="requestHeaders"></param>
        /// <returns></returns>
        public static string GetDepId(IHeaderDictionary requestHeaders)
        {
            StringValues result;
            string DepId = "";
            if (requestHeaders.TryGetValue("departmentId", out result))
            {
                DepId = result[0];
            }
            return DepId;
        }
        public static string GetRole(IHeaderDictionary requestHeaders)
        {
            StringValues result;
            string role = "";
            if (requestHeaders.TryGetValue("role", out result))
            {
                role = result[0];
            }
            return role;
        }
    }
}
